package com.ruoyi.charge.auth.controller;

import com.ruoyi.charge.auth.entity.req.LoginBody;
import com.ruoyi.charge.auth.entity.res.AccessTokenResponse;
import com.ruoyi.charge.service.IUserService;
import com.ruoyi.charge.vo.WxUserVo;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author fanqie
 * @date 2021-06-04
 */
@Api(value = "微信用户登陆", tags = {"微信用户登陆"})
@RestController
@RequestMapping("/charge/wx/auth")
public class WxLoginController {

    @Autowired
    private IUserService iUserService;

    /**
     * 微信小程序登录
     *
     * @return 返回token
     */
    @ApiOperation("登录")
    @GetMapping("/login")
    public AjaxResult login(@RequestParam("code") String code) {
        String openid = iUserService.getWxUserLoginInfo(code);
        return AjaxResult.success(openid);
    }
}
